//
// Created by EmFi on 2023/5/19.
//

#ifndef DBMS_STRINGUTIL_H
#define DBMS_STRINGUTIL_H

#include <string>
#include "../Database/Operation.h"

using namespace std;

class StringUtil {
public:
    static string timeInfoToString(TimeInfo info) {
        stringstream ss;
        ss << info.year << "-";
        if (info.month < 10) {
            ss << 0;
        }
        ss << info.month << "-";
        if (info.day < 10) {
            ss << 0;
        }
        ss << info.day << " ";
        if (info.hour < 10) {
            ss << 0;
        }
        ss << info.hour << ":";
        if (info.minute < 10) {
            ss << 0;
        }
        ss << info.minute << ":";
        if (info.second < 10) {
            ss << 0;
        }
        ss << info.second;
        return ss.str();
    }

    static string operationTypeToString(OperationType type) {
        switch (type) {
            case Insert:
                return "INSERT";
            case Delete:
                return "DELETE";
            case Update:
                return "UPDATE";
            case Select:
                return "SELECT";
        }
    }
};

#endif //DBMS_STRINGUTIL_H
